#ifndef CCONFIGERINSTANCE_H
#define CCONFIGERINSTANCE_H

#include "pch.h"
#include "Common/cconfigurer.h"
#include "Plugins/dirHelper/cDirHelper.h"
#include "Plugins/stringHelper/cStringHelper.h"



typedef struct _configerInstance
{
    _configerInstance()
    {
        using namespace libtool_sdk;

        char chValue[256] = {0};
        size_t nSize = sizeof(chValue);
        Helper::Tool_get_dll_path(chValue, (unsigned int*)&nSize);
        
        if(strlen(chValue) == 0)
        {
            Helper::Tool_get_current_dir(chValue, (unsigned int*)&nSize);
        }

        char chFinalString[256] = {0};
		strcpy(chFinalString, chValue);
        int iFinalLen = sizeof(chFinalString);

        std::string strFilePath(chFinalString);
#ifdef _WIN32
        strFilePath = strFilePath + "\\" + INI_FILE_NAME;
        Helper::Tool_ReplaceStringInStd(strFilePath.c_str(), "\\\\", "\\", chFinalString, iFinalLen);
#else
		strFilePath = strFilePath + "/" + INI_FILE_NAME;
        Helper::Tool_ReplaceStringInStd(strFilePath.c_str(), "//", "/", chFinalString, iFinalLen);
#endif // WIN32  

        printf("load ini file %s\n", chFinalString);

		if (!Helper::Tool_checkFileOrDirExsit(chFinalString))
        {
            cConfigurer::get_instance().createIniFile(chFinalString);
            cConfigurer::get_instance().loadIniFile(chFinalString);

            // cConfigurer::get_instance().set_section_value("camera", "ip", "0.0.0.0");

            cConfigurer::get_instance().set_section_value("Log", "Enable", "1" );
			cConfigurer::get_instance().set_section_value("Log", "rootPath", "");
            //cConfigurer::get_instance().set_section_value("Log", "Display", "0" );

            cConfigurer::get_instance().set_section_value("Result", "LinkEnable", "1");
        }
        else
        {
            cConfigurer::get_instance().loadIniFile(chFinalString);
        }
    }

    ~_configerInstance()
    {

    }

}configerInstance;

#endif // CCONFIGERINSTANCE_H
